<?php
/**
 * Created by PhpStorm.
 * User: think
 * Date: 2017/3/27
 * Time: 15:10
 */

namespace app\home\controller;


use app\api\model\page\comment\GetCommentByGoodsid;
use app\api\model\page\goods\GetGoods;
use app\api\model\page\note\GetNoteAnswerList;
use app\api\model\page\note\GetNoteInfo;
use app\api\model\page\note\GetNoteList;
use app\home\model\page\share\GetShareInfo;
use think\Controller;
use think\Request;

class Share extends Controller
{
    private $param;

    public function __construct()
    {
        parent::__construct();
        $this->param = Request::instance()->param();
    }

    public function getShareInfo()
    {
        $obj = new GetShareInfo();
        $ret = $obj->excute($this->param);
        return JSON($ret);
    }


    public function getNoteInfo()
    {
        $obj = new GetNoteInfo();
        $noteInfo = $obj->excute($this->param);
        if ($noteInfo['errno']) {
            return JSON($noteInfo);
        }
        $comment = new GetNoteAnswerList();
        $commentData = $comment->excute($this->param);
        //return JSON($commentData);
        $this->assign('noteinfo', $noteInfo['data']);
        $this->assign('replyinfo', $commentData['data']);
        return ($this->fetch('home/pages/share/note/notedetail'));
    }


    public function getGoodsInfo()
    {
        $obj = new GetGoods();
        $goods = $obj->excute($this->param);
        //return JSON($goods);
        if ($goods['errno']) {
            return JSON($goods);
        }
        $goods['data']['goods']['goods_img'] = explode('|', $goods['data']['goods']['goods_img']);
        $goods['data']['goods']['goods_desc'] = explode('|', $goods['data']['goods']['goods_desc']);
        //return JSON($goods);

        $obj = new GetCommentByGoodsid();
        $comment = $obj->excute($this->param);
        //return JSON($comment);
        $this->assign('goodsInfo', $goods['data']);
        $this->assign('commentInfo', $comment['data']);
        return ($this->fetch('home/pages/share/goods/goodsdetail'));
    }

}